import java.sql.*;

public class DataInsert {

	/**
	 * @param args
	 */
	public static void main(String[] args) throws SQLException
	{
		
		Connection conn=null;
		/*String username,password;
		System.out.println("Please Enter Username");
		Scanner un= new Scanner(System.in);	
		username=un.toString();
		System.out.println("Please Enter Password");
		Scanner pw= new Scanner(System.in);	
		password=pw.toString();*/
        try
        {
        	Class.forName ("com.mysql.jdbc.Driver").newInstance();
            conn = DriverManager.getConnection ("jdbc:mysql://csdb.csc.villanova.edu/auppalap", "auppalap", "fL00355727");
            System.out.println ("Database connection established"); 
        	Statement s= conn.createStatement();
             s.executeUpdate("INSERT INTO Users"+" VALUES"+"('anusha','anu')");
             s.executeQuery("select * from Users");
      	    ResultSet rs = s.getResultSet ();
      	    System.out.println("Before While");
      	   while(rs.next())
      	   {
      		   System.out.println("Inner While");
      	       String usname= rs.getString("uname");
      	       String pass= rs.getString("pwd");
      	       System.out.println ("Username is "+usname+" Password is "+pass);
      	               }
         }
         catch (Exception e)
         {
             System.out.println ("Cannot connect to database server" + e);

         }
         finally
         {
             if (conn != null)
             {
                 try
                 {
                 	 
                     conn.close ();
                     System.out.println ("Database connection terminated");
                 }
                 catch (Exception e) { /* ignore close errors */ }
             }
         }
             
           

	}

}
